﻿using GdNet.Core.Assistants;
using GdNet.WebFramework.Business.System;
using GdNet.WebFramework.Domain.Repositories.System;
using GdNet.WebFramework.Domain.System;

namespace GdNet.WebFramework.Business.Impl.System
{
    public class ModuleService : IModuleService
    {
        private readonly IModuleRepository _moduleRepository;

        public ModuleService(IModuleRepository moduleRepository)
        {
            _moduleRepository = moduleRepository;
        }

        public ModuleAction GetModuleAction(string moduleCode, string actionCode)
        {
            string codeProperty = ObjectAssistant.GetPropertyName<Module, string>(m => m.Code);
            var module = _moduleRepository.GetByProperty(codeProperty, moduleCode);
            return module.GetActionByCode(actionCode);
        }
    }
}
